package com.shsmi.application;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class PageController {


    @GetMapping("/index")
    public String index(HttpServletRequest request, HttpServletResponse response) {
        return "formDemo";
    }


    @GetMapping ("/{module}/{page}")
    public String modules(@PathVariable String module, @PathVariable String page, HttpServletRequest request,
                          HttpServletResponse response) throws IOException {
        if (module == null || page == null) {
            response.sendError(HttpServletResponse.SC_NOT_FOUND);
        }

        return module + "/" + page;
    }
}
